import {
  q as l,
  p as E,
  ap as F,
  X as b,
  f as H,
  H as P,
  av as w,
  aw as j,
  k as n,
  l as d,
  m as C,
  az as q,
  as as c,
  aG as G,
  at as v
} from "./index-30f27935.js";
import { f as S } from "./finance-301595de.js";
function $(B) {
  const p = l([]),
    r = l(!0);
  l({}), E();
  const y = l(1),
    f = l(10),
    s = l([]),
    x = l(""),
    _ = F("reload"),
    g = b({
      pageSize: 10,
      currentPage: 1,
      pageSizes: [10, 20, 30],
      total: 0,
      align: "right",
      background: !0,
      small: !1
    }),
    W = b({
      text: "正在加载第一页...",
      viewBox: "-10, -10, 50, 50",
      spinner: `
        <path class="path" d="
          M 30 15
          L 28 17
          M 25.61 25.61
          A 15 15, 0, 0, 1, 15 30
          A 15 15, 0, 1, 1, 27.99 7.5
          L 15 15
        " style="stroke-width: 4px; fill: rgba(0, 0, 0, 0)"/>
      `
    }),
    z = [
      {
        type: "selection",
        width: 55,
        align: "left",
        hide: ({ checkList: e }) => !e.includes("勾选列")
      },
      {
        label: "序号",
        type: "index",
        width: 70,
        hide: ({ checkList: e }) => !e.includes("序号列")
      },
      { label: "ID", prop: "id", minWidth: 50 },
      { label: "用户名", prop: "user_name", minWidth: 80 },
      { label: "手机号", prop: "user_phone", minWidth: 100 },
      {
        label: "瓶-库存",
        prop: "count_ping",
        minWidth: 100,
        formatter: ({ count_ping: e, symbol: t, content_ping: a }) =>
          e
            ? n("div", null, [
                " ",
                n(
                  d("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [t + " " + e] }
                ),
                n("div", null, [a])
              ])
            : n(
                d("el-tag"),
                { class: "mx-1", type: "info", effect: "light" },
                { default: () => [C("暂无")] }
              )
      },
      {
        label: "盒-库存",
        prop: "count_he",
        minWidth: 100,
        formatter: ({ count_he: e, symbol: t, content_he: a }) =>
          e
            ? n("div", null, [
                " ",
                n(
                  d("el-tag"),
                  { class: "mx-1", type: "success", effect: "light" },
                  { default: () => [t + " " + e] }
                ),
                n("div", null, [a])
              ])
            : n(
                d("el-tag"),
                { class: "mx-1", type: "info", effect: "light" },
                { default: () => [C("暂无")] }
              )
      },
      { label: "创建时间", prop: "create_time", minWidth: 100 }
    ],
    D = H(() => [
      "!h-[20px]",
      "reset-margin",
      "!text-gray-500",
      "dark:!text-white",
      "dark:hover:!text-primary"
    ]);
  async function I(e) {
    q(e);
  }
  async function J(e) {
    const t = { role_id: e.role_id },
      a = JSON.stringify(t),
      m = { value: c.enc.Base64.stringify(c.enc.Utf8.parse(a)) },
      i = await G(m);
    i.code == 200
      ? (v("删除成功", { type: "success" }), _())
      : v(i.msg, { type: "error" });
  }
  function k() {}
  function L(e) {
    (f.value = e), h(void 0, e);
  }
  function N(e) {
    (y.value = e), h(e, void 0);
  }
  function U(e) {}
  function V(e) {
    (W.text = `正在加载第${e}页...`),
      (r.value = !0),
      w(600).then(() => {
        r.value = !1;
      });
  }
  async function M(e, t = []) {
    (s.value = []),
      (r.value = !0),
      (x.value = e.user_phone),
      t.map(T => {
        const A = T,
          O = new Date(A);
        s.value.push(
          O.toLocaleDateString("zh-CN", {
            year: "numeric",
            month: "2-digit",
            day: "2-digit"
          })
        );
      });
    const a = {
        page: 1,
        pagesize: f.value,
        content: "count",
        user_phone: e.user_phone,
        type: e.type,
        start: s.value[0],
        end: s.value[1]
      },
      u = JSON.stringify(a),
      i = { value: c.enc.Base64.stringify(c.enc.Utf8.parse(u)) },
      { data: o } = await S(i);
    (p.value = o.count.data),
      (g.total = o.count.total),
      setTimeout(() => {
        r.value = !1;
      }, 500);
  }
  async function h(e = y.value, t = f.value) {
    const a = {
        page: e,
        pagesize: t,
        user_phone: x.value,
        start: s.value[0],
        end: s.value[1],
        content: "count"
      },
      u = JSON.stringify(a),
      i = { value: c.enc.Base64.stringify(c.enc.Utf8.parse(u)) },
      o = await S(i);
    o.code === 200
      ? ((p.value = o.data.count.data),
        (g.total = o.data.count.total),
        setTimeout(() => {
          r.value = !1;
        }, 500))
      : v(o.msg, { type: "error" });
  }
  const R = e => {
    e && (e.resetFields(), location.reload());
  };
  return (
    P(() => {
      w().then(() => {
        const { setWatermark: e } = j(B.value.getTableDoms().tableWrapper);
        e("后台项目", {
          font: "16px Microsoft YaHei",
          globalAlpha: 0.8,
          forever: !0,
          width: 252,
          height: 80
        });
      }),
        h();
    }),
    {
      loading: r,
      columns: z,
      dataList: p,
      pagination: g,
      buttonClass: D,
      formattedDate: s,
      onSearch: M,
      resetForm: R,
      handleaddUser: k,
      handleUpdate: I,
      handleDelete: J,
      handleSizeChange: L,
      handleCurrentChange: N,
      handleSelectionChange: U,
      onCurrentChange: V
    }
  );
}
export { $ as useRole };
